<template>
	<view class="page-e tn-safe-area-inset-bottom" style="width: 100%;">

		<!-- 顶部自定义导航 -->
		<tn-nav-bar :isBack="true" :bottomShadow="true" backgroundColor="#FFFFFF">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
				<view class="custom-nav__back">
					<text class="tn-text-bold tn-text-xl tn-color-black">数据中心</text>
				</view>
			</view>
		</tn-nav-bar>

		<view class="top-backgroup">
			<image src='https://tnuiimage.tnkjapp.com/my/my-bg4.png' mode='widthFix' class='backgroud-image'>
			</image>
		</view>

		<view class="tn-margin-left tn-margin-right" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			<!-- 图标logo/头像 -->
			<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom" style="margin-top: -400rpx;">
				<view class="justify-content-item">
					<view class="tn-flex tn-flex-col-center tn-flex-row-left">
						<view class="logo-pic tn-shadow">
							<view class="logo-image">
								<view class="tn-shadow-blur"
									:style="'background-image:url('+ authorInfo.qr_url +');width: 110rpx;height: 110rpx;background-size: cover;overflow: hidden;background-position: center center;'">
								</view>
							</view>
						</view>
						<view class="tn-padding-right">
							<view class="tn-padding-right tn-padding-left-sm">
								<text class="tn-color-wallpaper tn-text-xl tn-text-bold">{{ authorInfo.nickname}}</text>
								<text class=" tn-round tn-text-xs tn-bg-red tn-color-white tn-margin-left-sm" style="padding: 10rpx 20rpx;">v1 创作者</text>
							</view>
							<view class="tn-padding-right tn-padding-top-xs tn-padding-left-sm tn-text-ellipsis" style="max-width: 400rpx;">
								<text class="tn-color-gray">{{authorInfo.remark}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 汇总信息开始 -->
			<view class="tn-padding-top-sm tn-padding-bottom-sm"
				style="padding-bottom: 0;padding-top: 0;box-shadow: none;border-radius: unset;">
				<view class="tn-flex tn-flex-row-center tn-radius">

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('/pageA/author/share')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper">{{ totalData.share || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">分享</text>
							</view>
						</view>
					</view>

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('/pageA/author/collection')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper">{{ totalData.collection || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">收藏</text>
							</view>
						</view>
					</view>

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('/pageA/author/attention')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper">{{ totalData.fans || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">关注</text>
							</view>
						</view>
					</view>

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper" style="text-align: center !important;">{{ totalData.download || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">下载</text>
							</view>
						</view>
					</view>

				</view>
			</view>
			<!-- 信息汇总结束 -->

			<!-- 创作者开始-->
			<view class="wallpaper-shadow tn-margin-top-lg tn-padding-top-sm tn-padding-bottom-sm tn-bg-white">
				<view class="card-tool">
					<view class="card-tool-left">
						近7日数据
					</view>
					<view class="card-tool-right">
						数据两小数刷新一次<!-- 更多数据 > -->
					</view>
				</view>
				<view class="tn-flex tn-flex-row-center tn-radius tn-padding-top">

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper">{{ getCurrentWeek.share || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">分享数</text>
							</view>
						</view>
					</view>

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper">{{ getCurrentWeek.collection || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">收藏数</text>
							</view>
						</view>
					</view>

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper">{{ getCurrentWeek.fans || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">涨粉数</text>
							</view>
						</view>
					</view>

					<view class="tn-padding-sm tn-margin-xs tn-radius" @click="tn('')">
						<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
							<view class="icon12__item--icon tn-flex tn-flex-row-center tn-flex-col-center">
								<view class="tn-color-wallpaper">{{ getCurrentWeek.download || 0 }}</view>
							</view>
							<view class="tn-text-center">
								<text class="tn-text-ellipsis">下载数</text>
							</view>
						</view>
					</view>

				</view>
			</view>
			<!-- 创作者功能结束 -->

			<!-- 活动结束-->
			<view class="wallpaper-shadow tn-margin tn-padding" style="margin: 30rpx 0;">
				
				<view :style="'margin-bottom:' + (index == 2 ? '' : '50rpx') +';'" v-for="(item, index) in 3">
					<view class="tn-flex tn-flex-col-top">
						<view class="">
							<view class="logo-pic">
								<view class="logo-image">
									<view class=""
										style="background-image:url('http://qiniucloud.qqdeveloper.com/60b932209c6a7a1ef775163dbff4981d.png');width: 100%;height: 100%;background-size: cover;">
									</view>
								</view>
							</view>
						</view>
						<view class="tn-padding-left-sm" style="width: 100%;">
							<view class="tn-flex tn-flex-row-between tn-flex-col-between" style="margin-top: 30rpx;">
								<view class="justify-content-item">
									<text class="tn-color-wallpaper tn-text-lg tn-text-bold">创作活动{{index + 1}}</text>
								</view>
							</view>
							<view class=" tn-padding-top-xs  tn-text-ellipsis-2">
								<text class="tn-color-gray">兔兔找图预览版正式发布啦，快来关注吧快来关注吧快来关注吧</text>
							</view>
						</view>
					</view>
					
					<view class="tn-flex tn-flex-row-between tn-flex-col-between tn-margin-top-sm">
						<view class="justify-content-item tn-color-gray tn-text-center tn-color-gray">
							<text class="tn-icon-time tn-padding-right-xs tn-padding-left-xs tn-text-df"></text>
							<text class="tn-text-sm">截止时间: 2023-04-02 06:27:12</text>
						</view>
						<view class="justify-content-item tn-round tn-text-xs tn-bg-blue--light tn-color-blue"
							style="padding: 5rpx 15rpx;">
							<text class="tn-padding-right-xs">#</text> 官 方
						</view>
					</view>
				</view>
				
			</view>
			<!-- 活动结束 -->

		</view>

	</view>
</template>

<script>
	import { authorInfo, getCurrentWeek, totalData} from '@/utils/api/author.js'
	export default {
		name: 'Author',
		data() {
			return {
				authorInfo: {},
				col: 4,
				getCurrentWeek: {},
				totalData: {},
			}
		},
		computed: {
			// 兼容小程序
			gridItemWidth() {
				return 100 / this.col + '%'
			}
		},
		onShow() {
			this.getAuthorInfo()
		},
		methods: {
			// 获取作者信息
			getAuthorInfo() {
				uni.showLoading({
					title: "数据努力加载中",
					mask: true,
				})
				authorInfo().then(res => {
					uni.hideLoading()
					if (res.code == 0) {
						uni.navigateTo({
							url: "/pageA/author/ident"
						})
						return
					}
					if (res.code != 3) {
						this.$func.showToast(res.msg)
						return
					}
					this.authorInfo = res
					this.getCurrentWeekData()
					this.getTotalData()
				})
			},
			getCurrentWeekData() {
				getCurrentWeek().then(res => {
					this.getCurrentWeek = res
				})
			},
			getTotalData() {
				totalData().then(res => {
					this.totalData = res
				})
			},
			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			//拨打固定电话
			callPhoneNumber() {
				uni.makePhoneCall({
					phoneNumber: "188888888",
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.card-tool {
		padding: 0 30rpx;
		font-size: 30rpx;
		display: flex;
		font-weight: 600;
		justify-content: space-between;
	}

	.card-tool-right {
		font-size: 20rpx;
		color: gray;
		font-weight: 400;
	}

	.tn-flex-row-center {
		justify-content: space-between;
	}

	.page-e {
		max-height: 100vh;
	}

	/* 底部安全边距 start*/
	.tn-tabbar-height {
		min-height: 20rpx;
		height: calc(40rpx + env(safe-area-inset-bottom) / 2);
		height: calc(40rpx + constant(safe-area-inset-bottom));
	}

	.tn-color-wallpaper {
		color: #1D2541;
	}


	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			margin: auto 30rpx;
			font-size: 40rpx;
			margin-right: 10rpx;
			flex-basis: 5%;
			width: 100rpx;
			position: absolute;
		}
	}

	/* 自定义导航栏内容 end */

	/* 顶部背景图 start */
	.top-backgroup {
		height: 450rpx;
		z-index: -1;

		.backgroud-image {
			width: 100%;
			height: 450rpx;
			// z-index: -1;
		}
	}

	/* 顶部背景图 end */


	/* 图标容器5 start */
	.icon5 {
		&__item {
			// width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 0rpx;
			margin: 0rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 96rpx;
				height: 96rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;
			}
		}
	}

	/* 用户头像 start */
	.logo-image {
		width: 110rpx;
		height: 110rpx;
		position: relative;
		overflow: hidden;
		border-radius: 50%;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border: 8rpx solid rgba(255, 255, 255, 0.05);
		box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
		border-radius: 50%;
		overflow: hidden;
		// background-color: #FFFFFF;
	}

	/* 页面阴影 start*/
	.wallpaper-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	/* 页面阴影 end*/

	/* 图标容器15 start */
	.icon15 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;


				}
			}
		}
	}

	/* 图标容器12 start */
	.tn-three {
		position: absolute;
		top: 50%;
		right: 50%;
		bottom: 50%;
		left: 50%;
		transform: translate(-38rpx, -16rpx) rotateX(30deg) rotateY(20deg) rotateZ(-30deg);
		text-shadow: -1rpx 2rpx 0 #f0f0f0, -2rpx 4rpx 0 #f0f0f0, -10rpx 20rpx 30rpx rgba(0, 0, 0, 0.2);
	}

	.icon20 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://tnuiimage.tnkjapp.com/cool_bg_image/icon_bg.png);
				}
			}
		}
	}


	/* 积分数字 */
	.button-number {
		width: 100%;
		height: 150rpx;
		border-radius: 15rpx;
		position: relative;
		z-index: 1;

		&::after {
			content: " ";
			position: absolute;
			z-index: -1;
			width: 100%;
			height: 100%;
			left: 0;
			bottom: 0;
			border-radius: inherit;
			opacity: 1;
			transform: scale(1, 1);
			background-size: 100% 100%;
			background-image: url(https://tnuiimage.tnkjapp.com/cool_bg_image/icon_bg.png);
		}
	}


	/* 图标容器12 start */
	.icon12 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				// width: 15rpx;
				height: 15rpx;
				font-size: 40rpx;
				border-radius: 50%;
				margin-bottom: 38rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;

				}
			}
		}
	}

	/* 图标容器1 start */
	.icon1 {
		&__item {
			// width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 40rpx;
				height: 40rpx;
				font-size: 40rpx;
				border-radius: 50%;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://tnuiimage.tnkjapp.com/cool_bg_image/icon_bg.png);
				}
			}
		}
	}

	/* 图标容器1 end */
</style>